package com.fyb.lock;

public class Lock {

    public static void main(String[] args) throws InterruptedException {


        A a  =new A();
        long start = System.currentTimeMillis();

        System.out.println(start);

        Thread t1=new Thread(() -> {
            for (int i = 0; i < 10000000; i++) {
                a.increase();
            }
        });

        Thread t2=new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 10000000; i++) {
                    a.increase();
                }
            }
        });

        t1.start();
        t2.start();
        for(int  i= 0; i < 10000000; i++) {
            a.increase();
        }

        t1.join();
        t2.join();
        long end=System.currentTimeMillis();
        System.out.println(end);
        System.out.println(String.format("%sms",end-start));
        System.out.println(a.getNum());
    }
}
